package com.wang.nowcoder.util;

import com.wang.nowcoder.pojo.User;
import org.springframework.stereotype.Component;

/**
 * @author wang
 * @ClassName HostHolder
 * @Description 持有用户的信息，用于代替session对象
 * @date 2021/12/20 19:35
 * @Version 1.0
 */
@Component
public class HostHolder {
    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUsers(User user){
        users.set(user);
    }
    public User getUser(){
        return users.get();
    }
    public void clear(){
        users.remove();
    }
}
